"""
Problem 56: https://projecteuler.net/problem=56

A googol (10^100) is a massive number: one followed by one-hundred zeros;
100^100 is almost unimaginably large: one followed by two-hundred zeros.
Despite their size, the sum of the digits in each number is only 1.

Considering natural numbers of the form, a^b, where a, b < 100,
what is the maximum digital sum?
"""

# _*_ conding:UTF-8 _*_
'''
@author = Kuperain
@email = kuperain@aliyun.com
@IDE = VSCODE Python3.8.3
@creat_time = 2022/5/18
'''



def solution(alimit: int = 100,blimit:int =100) -> int:

    maxdigit = 0
    res_a = 1
    res_b = 1
    for a in range(1,alimit):
        for b in range(1,blimit):
            n = a**b
            sumofdigits = sum(map(int,str(n)))
            if sumofdigits>maxdigit:
                maxdigit = sumofdigits
                res_a = a
                res_b = b
    
    print(f'{res_a}^{res_b}, the sum of digits is {maxdigit}.')
    return maxdigit


if __name__ == "__main__":
    import doctest
    doctest.testmod(verbose=False)

    print(solution())
    # 972
